import { Component, Injector } from "@angular/core";
import { AppComponentBase } from "@shared/common/app-component-base";
import { PipelineListDto } from "@shared/service-proxies/service-proxies";
import {
  PipelineNodeServiceProxy,
  SimpleTechDocListDto,
} from "@shared/service-proxies/service-proxies";
import { finalize } from "rxjs/operators";
import { appModuleAnimation } from "@shared/animations/routerTransition";

@Component({
  selector: "gy21",
  templateUrl: "./gy21.component.html",
  animations: [appModuleAnimation()],
})
export class GY21ModalComponent extends AppComponentBase {
  isLoading = false;
  saving = false;

  remark = "";

  pipe: PipelineListDto = new PipelineListDto();

  boundedTechDoc = new SimpleTechDocListDto();

  constructor(
    injector: Injector,
    private _taskServiceProxy: PipelineNodeServiceProxy
  ) {
    super(injector);
    //this.actBase = actBase;
  }

  load(pipe: PipelineListDto): void {
    this.pipe = pipe;
    this.isLoading = true;
    this._taskServiceProxy.getTechDocList(pipe.id).subscribe((result) => {
      this.boundedTechDoc = result.techDocs.filter(
        (el) => el.codeId === result.boundedCodeId
      )[0];
      this.isLoading = false;
    });

    // this._taskServiceProxy.getCurrentActRemark(pipe.id).subscribe(result => {
    //   this.remark = typeof result === 'object' ? '' : result;
    // });
  }

  save(): void {
    this.saving = true;

    // this._taskServiceProxy
    //   .setCurrentActRemark(this.pipe.id, this.remark)
    //   .pipe(
    //     finalize(() => {
    //       this.saving = false;
    //     })
    //   )
    //   .subscribe(result => {
    //     this.notify.success('记录备注成功');
    //   });
  }
}
